package com.example.cslp.mapper;


import com.example.cslp.pojo.entity.Comment;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;
@Mapper
@Repository
public interface CommentMapper {
    //增加评论
    //增加评论
    @Insert("insert into comment (value, username, course_id, yes, no) values " +
            "(#{value}, #{username}, #{course_id}, #{yes}, #{no})")
    Boolean addComment(Comment comment);
    //删除评论
    @Delete("delete from comment where id=#{id}")
    Boolean deleteComment(String id);

    //获取某门课的评论
    @Select("select * from comment where course_id=#{c_id}")
    List<Comment> queryComment(Integer c_id);

    //评论点赞
    @Update("update comment set yes=yes+1 where id=#{commentId}")
    Boolean yesComment(Integer commentId);

    //评论点踩
    @Update("update comment set no=no+1 where id=#{commentId}")
    Boolean noComment(Integer commentId);
}
